
# generate pandigitals
def gen_pds(left, bits):
    if bits == 1:
        return map(str, left)
    else:
        ret = []
        for x in left:
            new_left = left[:]
            new_left.remove(x)
            ret += map(lambda s : str(x)  + s, gen_pds(new_left, bits-1))
        return ret

prods = set() 
for s in gen_pds(range(1, 10), 9):
    for i in [1, 2]:
        a = int(s[:i])
        b = int(s[i:5])
        c = int(s[5:])
        if a * b == c:
            prods.add(c)

print sum(prods)



